package com.sts.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sts.entity.RolePermission;
import com.sts.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface RolePermissionMapper extends BaseMapper<RolePermission> {
    @Delete("DELETE FROM role_permission WHERE role_id = #{roleId}")
    void deleteByRoleId(@Param("roleId") Long roleId);

    @Insert("<script>" +
            "INSERT INTO role_permission(role_id, perm_id) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.roleId}, #{item.permId})" +
            "</foreach>" +
            "</script>")
    void insertBatch(@Param("list") List<RolePermission> list);
}
